home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / Macintosh Sample Code / SC.020.Transformer / Transformer.r < prev    next >
Encoding:
Text File  |  1989-09-30  |  13.5 KB  |  442 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    BitMap Transformer
  6. #
  7. #    Transformer.r    -    Rez Source
  8. #
  9. #    Copyright © 1989 Apple Computer, Inc.
  10. #    All rights reserved.
  11. #
  12. #    Versions:
  13. #                1.0                         10/89
  14. #
  15. #    Components:
  16. #                MTransformer.p                October 1, 1989
  17. #                UTransformer.p                October 1, 1989
  18. #                UTransformer.inc1.p         October 1, 1989
  19. #                Transformer.c                October 1, 1989
  20. #                Transformer.r                October 1, 1989
  21. #                Transformer.MAMake            October 1, 1989
  22. #                ProjInit                    October 1, 1989
  23. #                The BitMap Transmogrifier    October 1, 1989
  24. #
  25. #    Requirements:
  26. #                MacApp® 2.0ß9                July 10, 1989
  27. #
  28. # "Transformers" is a sample program that demonstrates how to translate,
  29. # rotate, and scale bitmaps. It uses a MacApp shell to open file, open
  30. # windows, and handle menus, but the core routine is written in vanilla C.
  31. #
  32. ------------------------------------------------------------------------------*/
  33.  
  34.  
  35. // • Auto-Include the requirements for this source
  36. #ifndef __TYPES.R__
  37. #include "Types.r"
  38. #endif
  39.  
  40. #ifndef __SYSTYPES.R__
  41. #include "SysTypes.r"
  42. #endif __SYSTYPES.R__
  43.  
  44. #ifndef __MacAppTypes__
  45. #include "MacAppTypes.r"
  46. #endif
  47.  
  48. #if qTemplateViews
  49. #ifndef __ViewTypes__
  50. #include "ViewTypes.r"
  51. #endif
  52. #endif
  53.  
  54.  
  55. // Get the application's CODE.  Note that this is done this way so that the application can
  56. // be linked and/or rezzed separately.  Also, Rez currently (MPW 3.0) does not support
  57. // -align longword simultaneously with the -append option (but it only tells you if you're
  58. // getting -p progress indication).
  59. include $$Shell("ObjApp")$$Shell("XAppName") 'CODE';
  60.  
  61. // Basic resources for various purposes.
  62. // Self evident from their names!
  63. include "MacApp.rsrc";
  64. include "Dialog.rsrc";
  65. // include "Printing.rsrc";
  66.  
  67. #if qDebug
  68. include "Debug.rsrc";
  69. #endif
  70.  
  71.  
  72. // Now include the "default" resources
  73. // Note: you can pick and choose to selectively replace defaults in your own Rez source.
  74. // #if qTemplateViews
  75. // include "Defaults.rsrc"  'view' (kDefaultViewID);
  76. // include "Defaults.rsrc"  'view' (kDefaultWindowID);
  77. // #endif
  78.  
  79. include "Defaults.rsrc"  'ALRT' (phAboutApp);
  80. include "Defaults.rsrc"  'cmnu' (128);    // Buzzwords
  81. include "Defaults.rsrc"  'cmnu' (mApple);
  82. include "Defaults.rsrc"  'cmnu' (mEdit);
  83. // include "Defaults.rsrc"  'cmnu' (mFile);
  84. include "Defaults.rsrc"  'DITL' (phAboutApp);
  85. // include "Defaults.rsrc"  'MBAR' (kMBarDisplayed);
  86. // include "Defaults.rsrc"  'SIZE' (-1);
  87. include "Defaults.rsrc"  'STR#' (kDefaultCredits);
  88. include "Defaults.rsrc"  'WIND' (kDefaultWindowID);
  89.  
  90. // Get the default MacApp® application icon and necessary bundling rsrcs
  91. include "Defaults.rsrc"  'MApp' (0);
  92. include "Defaults.rsrc"  'FREF' (128);
  93. include "Defaults.rsrc"  'BNDL' (128);
  94. include "Defaults.rsrc"  'ICN#' (128);
  95.  
  96. // Get the default Version resources
  97. // include "Defaults.rsrc"  'vers' (1);        // Application or file specific
  98. include "Defaults.rsrc"  'vers' (2);        // Overall package
  99.  
  100. /*--------------------------------------------------------------------------------
  101.  The revision of this particular file
  102. --------------------------------------------------------------------------------*/
  103. RESOURCE 'vers' (1, purgeable) {
  104.     0x01,
  105.     0x00,
  106.     final,
  107.     0x01,
  108.     verUs,
  109.     "1.0",
  110.     "Transformer 1.0, Macintosh Developer Technical Support, © Apple Computer, Inc. 1989"
  111. };
  112.  
  113.  
  114. // *****************************************************************************
  115. //
  116. // My own custom stuff (windows, menus, you know?)
  117. //
  118.  
  119. #define kOptionsDialog        1100
  120.  
  121. #define mTransform            4
  122. #define cNormal                1000
  123. #define cRot90                1001
  124. #define cRot45                1002
  125. #define cScale2                1003
  126. #define cScaleHalf            1004
  127. #define cRot45ScaleHalf        1005
  128. #define cCustom                1006
  129.  
  130. resource 'cmnu' (mFile,
  131. #if qNames
  132. "mFile",
  133. #endif
  134. nonpurgeable) {
  135.     mFile,
  136.     textMenuProc,
  137.     0x7FFFFFFD,
  138.     enabled,
  139.     "File",
  140.     {
  141.     "Open…",            noIcon, "O",    noMark, plain, cOpen;
  142.     "Close",            noIcon, "W",    noMark, plain, cClose;
  143.     "-",                noIcon, noKey,    noMark, plain, nocommand;
  144.     "Quit",                noIcon, "Q",    noMark, plain, cQuit
  145.     }
  146. };
  147.  
  148.  
  149. resource 'cmnu' (mTransform,
  150. #if qNames
  151. "mTransform",
  152. #endif
  153. nonpurgeable) {
  154.     mTransform,
  155.     textMenuProc,
  156.     0x7FFFFFFD,
  157.     enabled,
  158.     "Transform",
  159.     {
  160.     "Display Normally",    noIcon, noKey,    noMark, plain, cNormal;
  161.     "-",                noIcon, noKey,    noMark, plain, nocommand;
  162.     "Rotate 90",        noIcon, noKey,    noMark, plain, cRot90;
  163.     "Rotate 45",        noIcon, noKey,    noMark, plain, cRot45;
  164.     "Scale Double",        noIcon, noKey,    noMark, plain, cScale2;
  165.     "Scale Half",        noIcon, noKey,    noMark, plain, cScaleHalf;
  166.     "Rotate 45 Scale Half",        noIcon, noKey,    noMark, plain, cRot45ScaleHalf;
  167.     "-",                noIcon, noKey,    noMark, plain, nocommand;
  168.     "Custom…",            noIcon, "T",    noMark, plain, cCustom;
  169.     }
  170. };
  171.  
  172.  
  173. resource 'MBAR' (kMBarDisplayed,
  174. #if qNames
  175. "kMBarDisplayed",
  176. #endif
  177. nonpurgeable) {
  178.  
  179.     {mApple; mFile; mEdit; mTransform}
  180. };
  181.  
  182. resource 'SIZE' (-1) {
  183.     saveScreen,
  184.     acceptSuspendResumeEvents,
  185.     enableOptionSwitch,
  186.     canBackground,
  187.     MultiFinderAware,
  188.     backgroundAndForeground,
  189.     dontGetFrontClicks,
  190.     ignoreChildDiedEvents,
  191.     is32BitCompatible,
  192.     reserved,
  193.     reserved,
  194.     reserved,
  195.     reserved,
  196.     reserved,
  197.     reserved,
  198.     reserved,
  199. #if qDebug
  200.     410 * 1024,
  201.     410 * 1024
  202. #else
  203.     330 * 1024,
  204.     220 * 1024
  205. #endif
  206. };
  207.  
  208. resource 'seg!' (256,
  209. #if qNames
  210. "TransformerSeg!",
  211. #endif
  212.     purgeable) {
  213.     {
  214.         "GOpen";
  215.         "GFile";
  216.         "GSelCommand";
  217.     }
  218. };
  219.  
  220.  
  221.  
  222. #if qTemplateViews
  223. resource 'view' (kDefaultWindowID,
  224. #if qNames
  225. "kDefaultWindowID",
  226. #endif
  227.     purgeable) {
  228.     {
  229.         root, 'WIND', { 50, 20 }, { 260, 430 }, sizeVariable, sizeVariable, shown, enabled,
  230.         Window        { "", zoomDocProc, goAwayBox, resizable, modeless,
  231.                     ignoreFirstClick,
  232.                     freeOnClosing, disposeOnFree, closesDocument, openWithDocument, dontAdaptToScreen,
  233.                     stagger, forceOnScreen, dontCenter, 'DFLT', "" };
  234.  
  235.         'WIND', 'SCLR',    { 0, 0 }, { 260-kSBarSizeMinus1, 430-kSBarSizeMinus1 },
  236.         sizeRelSuperView, sizeRelSuperView, shown, enabled,
  237.         Scroller    { "", vertScrollBar, horzScrollBar, 0, 0, 16, 16,
  238.                     vertConstrain, horzConstrain, { 0, 0, 0, 0 } };
  239.  
  240.         'SCLR',IncludeViews    { kDefaultViewID }
  241.     }
  242. };
  243.  
  244. resource 'view' (kDefaultViewID,
  245. #if qNames
  246. "kDefaultViewID",
  247. #endif
  248.     purgeable) {
  249.     {
  250.         root, 'DFLT', { 0, 0 }, { 720, 576 }, sizeFixed, sizeFixed, shown, enabled,
  251.         DefaultView        {""}                // A ClassName can be put in this string
  252.                                             // or do a RegisterStdType to point to
  253.                                             // something to create for a "Default View"
  254.     }
  255. };
  256.  
  257.  
  258. resource 'view' (kOptionsDialog,
  259. #if qNames
  260.  "kOptionsDialog",
  261. #endif
  262.     purgeable) {
  263.     {
  264.         root, 'wind',
  265.         { 50, 40 }, { 256, 336 }, sizeVariable, sizeVariable, shown, enabled,
  266.         Window { "TWindow", dBoxProc, noGoAwayBox, notResizable, modal, ignoreFirstClick,
  267.             freeOnClosing, disposeOnFree, doesntCloseDocument, openWithDocument, dontAdaptToScreen,
  268.             dontStagger, dontForceOnScreen, center, 'ndeg', "<<<>>>" },
  269.  
  270.         'wind', 'DLOG',
  271.         { 0, 0 }, { 256, 336 }, sizeSuperView, sizeSuperView, shown, enabled,
  272.         DialogView { "TDialogView", 'OKOK', 'CANC' },
  273.  
  274.         'DLOG', noid,
  275.         { 10, 16 }, { 16, 304 }, sizeFixed, sizeFixed, shown, disabled,
  276.         StaticText { "TStaticText", adnLineBottom, {1, 1}, sizeable, notDimmed, notHilited,
  277.             doesntDismiss, {0, 0, 0, 0}, plain, 14, { 0x0, 0x0, 0x0 }, "New York", justCenter,
  278.             "Options" },
  279.  
  280.         'DLOG', noid,
  281.         { 48, 16 }, { 16, 144 }, sizeFixed, sizeFixed, shown, disabled,
  282.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  283.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justRight,
  284.             "Amount of Rotation:" },
  285.  
  286.         'DLOG', noid,
  287.         { 80, 16 }, { 16, 144 }, sizeFixed, sizeFixed, shown, disabled,
  288.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  289.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justRight,
  290.             "Amount of Scaling:" },
  291.  
  292.         'DLOG', noid,
  293.         { 112, 16 }, { 16, 144 }, sizeFixed, sizeFixed, shown, disabled,
  294.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  295.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justRight,
  296.             "Center of Rotation:" },
  297.  
  298.         'DLOG', noid,
  299.         { 144, 16 }, { 16, 144 }, sizeFixed, sizeFixed, shown, disabled,
  300.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  301.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justRight,
  302.             "Translation of Center:" },
  303.  
  304.         'DLOG', noid,
  305.         { 48, 256 }, { 16, 64 }, sizeFixed, sizeFixed, shown, disabled,
  306.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  307.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  308.             "degrees" },
  309.  
  310.         'DLOG', noid,
  311.         { 80, 176 }, { 16, 16 }, sizeFixed, sizeFixed, shown, disabled,
  312.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  313.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  314.             "X:" },
  315.  
  316.         'DLOG', noid,
  317.         { 112, 176 }, { 16, 16 }, sizeFixed, sizeFixed, shown, disabled,
  318.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  319.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  320.             "X:" },
  321.  
  322.         'DLOG', noid,
  323.         { 144, 176 }, { 16, 16 }, sizeFixed, sizeFixed, shown, disabled,
  324.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  325.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  326.             "X:" },
  327.  
  328.         'DLOG', noid,
  329.         { 80, 256 }, { 16, 16 }, sizeFixed, sizeFixed, shown, disabled,
  330.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  331.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  332.             "Y:" },
  333.  
  334.         'DLOG', noid,
  335.         { 112, 256 }, { 16, 16 }, sizeFixed, sizeFixed, shown, disabled,
  336.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  337.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  338.             "Y:" },
  339.  
  340.         'DLOG', noid,
  341.         { 144, 256 }, { 16, 16 }, sizeFixed, sizeFixed, shown, disabled,
  342.         StaticText { "TStaticText", adnNone, {1, 1}, sizeable, notDimmed, notHilited,
  343.             doesntDismiss, {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  344.             "Y:" },
  345.  
  346.         'DLOG', 'ndeg',
  347.         { 46, 192 }, { 20, 48 }, sizeFixed, sizeFixed, shown, enabled,
  348.         NumberText { "TNumberText", adnFrame, {1, 1}, sizeable, notDimmed, notHilited,
  349.             doesntDismiss, {2, 2, 2, 2}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  350.             "", unlimited, 0b11110000000000000000000100000000, 0, 0, 359 },
  351.  
  352.         'DLOG', 'nscx',
  353.         { 78, 192 }, { 20, 48 }, sizeFixed, sizeFixed, shown, enabled,
  354.         NumberText { "TExtNumberText", adnFrame, {1, 1}, sizeable, notDimmed, notHilited,
  355.             doesntDismiss, {2, 2, 2, 2}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  356.             "", unlimited, 0b11110000000000000000000100000000, 1, 0, 100 },
  357.  
  358.         'DLOG', 'nscy',
  359.         { 78, 272 }, { 20, 48 }, sizeFixed, sizeFixed, shown, enabled,
  360.         NumberText { "TExtNumberText", adnFrame, {1, 1}, sizeable, notDimmed, notHilited,
  361.             doesntDismiss, {2, 2, 2, 2}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  362.             "", unlimited, 0b11110000000000000000000100000000, 1, 0, 100 },
  363.  
  364.         'DLOG', 'ncrx',
  365.         { 110, 192 }, { 20, 48 }, sizeFixed, sizeFixed, shown, enabled,
  366.         NumberText { "TNumberText", adnFrame, {1, 1}, sizeable, notDimmed, notHilited,
  367.             doesntDismiss, {2, 2, 2, 2}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  368.             "", unlimited, 0b11110000000000000000000100000000, 288, 0, 575 },
  369.  
  370.         'DLOG', 'ncry',
  371.         { 110, 272 }, { 20, 48 }, sizeFixed, sizeFixed, shown, enabled,
  372.         NumberText { "TNumberText", adnFrame, {1, 1}, sizeable, notDimmed, notHilited,
  373.             doesntDismiss, {2, 2, 2, 2}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  374.             "", unlimited, 0b11110000000000000000000100000000, 360, 0, 719 },
  375.  
  376.         'DLOG', 'ntrx',
  377.         { 142, 192 }, { 20, 48 }, sizeFixed, sizeFixed, shown, enabled,
  378.         NumberText { "TNumberText", adnFrame, {1, 1}, sizeable, notDimmed, notHilited,
  379.             doesntDismiss, {2, 2, 2, 2}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  380.             "", unlimited, 0b11110000000000000000000100000000, 288, 0, 575 },
  381.  
  382.         'DLOG', 'ntry',
  383.         { 142, 272 }, { 20, 48 }, sizeFixed, sizeFixed, shown, enabled,
  384.         NumberText { "TNumberText", adnFrame, {1, 1}, sizeable, notDimmed, notHilited,
  385.             doesntDismiss, {2, 2, 2, 2}, plain, 0, { 0x0, 0x0, 0x0 }, "", justLeft,
  386.             "", unlimited, 0b11110000000000000000000100000000, 360, 0, 719 },
  387.  
  388.         'DLOG', 'OKOK',
  389.         { 188, 28 }, { 32, 104 }, sizeFixed, sizeFixed, shown, enabled,
  390.         Button { "TButton", adnRRect, {3, 3}, sizeable, notDimmed, notHilited, dismisses,
  391.             {4, 4, 4, 4}, plain, 0, { 0x0, 0x0, 0x0 }, "", "OK" },
  392.  
  393.         'DLOG', 'CANC',
  394.         { 192, 208 }, { 24, 96 }, sizeFixed, sizeFixed, shown, enabled,
  395.         Button { "TButton", adnNone, {1, 1}, sizeable, notDimmed, notHilited, dismisses,
  396.             {0, 0, 0, 0}, plain, 0, { 0x0, 0x0, 0x0 }, "", "Cancel" },
  397.     }
  398. };
  399.  
  400. #endif
  401.  
  402.  
  403. // Spinning cursor support
  404.  
  405. data 'acur' (0, preload) {
  406.     $"00 04 00 00 00 80 00 00 00 81 00 00 00 82 00 00"    /* .....Ä...Å...Ç.. */
  407.     $"00 83 00 00"                                        /* .É.. */
  408. };
  409.  
  410. resource 'CURS' (128, preload) {
  411.     $"07 C0 1F 30 3F 08 7F 04 7F 04 FF 02 FF 02 FF FE"
  412.     $"81 FE 81 FE 41 FC 41 FC 21 F8 19 F0 07 C0",
  413.     $"07 C0 1F F0 3F F8 7F FC 7F FC FF FE FF FE FF FE"
  414.     $"FF FE FF FE 7F FC 7F FC 3F F8 1F F0 07 C0",
  415.     {7, 7}
  416. };
  417.  
  418. resource 'CURS' (129, preload) {
  419.     $"07 C0 1F F0 3F F8 5F F4 4F E4 87 C2 83 82 81 02"
  420.     $"83 82 87 C2 4F E4 5F F4 3F F8 1F F0 07 C0",
  421.     $"07 C0 1F F0 3F F8 7F FC 7F FC FF FE FF FE FF FE"
  422.     $"FF FE FF FE 7F FC 7F FC 3F F8 1F F0 07 C0",
  423.     {7, 7}
  424. };
  425.  
  426. resource 'CURS' (130, preload) {
  427.     $"07 C0 19 F0 21 F8 41 FC 41 FC 81 FE 81 FE FF FE"
  428.     $"FF 02 FF 02 7F 04 7F 04 3F 08 1F 30 07 C0",
  429.     $"07 C0 1F F0 3F F8 7F FC 7F FC FF FE FF FE FF FE"
  430.     $"FF FE FF FE 7F FC 7F FC 3F F8 1F F0 07 C0",
  431.     {7, 7}
  432. };
  433.  
  434. resource 'CURS' (131, preload) {
  435.     $"07 C0 18 30 20 08 70 1C 78 3C FC 7E FE FE FF FE"
  436.     $"FE FE FC 7E 78 3C 70 1C 20 08 18 30 07 C0",
  437.     $"07 C0 1F F0 3F F8 7F FC 7F FC FF FE FF FE FF FE"
  438.     $"FF FE FF FE 7F FC 7F FC 3F F8 1F F0 07 C0",
  439.     {7, 7}
  440. };
  441.  
  442.